package com.wh.simpleredis.controller;

import com.alibaba.fastjson.JSONObject;
import com.wh.simpleredis.server.RedisServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Auther: HuiEr
 * @Date: 2020/3/6 21:13
 * @Description
 */
@RestController
public class RedisController {
    @Autowired
    private RedisServer redisServer;

    @RequestMapping("addValue")
    public String addValue(String key, String value) {
        redisServer.addValue(key, value);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(key, value);
        return jsonObject.toJSONString();
    }

    @RequestMapping("getValue")
    public String getValue(String key) {
        return redisServer.getValue(key);
    }

    @RequestMapping("produceStock")
    public String produceStock() {
        return redisServer.produceStock();
    }

    @RequestMapping("produceStockRedisson")
    public String produceStockRedisson() {
        return redisServer.produceStockRedisson();
    }
    @RequestMapping("saveduixiang")
    public String saveduixiang() {
        return redisServer.saveduixiang();
    }
    @RequestMapping("getduixiang")
    public String getduixiang() {
        return redisServer.getduixiang();

    }
}